package com.asen.commons.core.base.model;

import com.asen.commons.core.base.ObjectEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.Objects;

/**
 * 枚举项
 *
 * @author ls
 * @version 1.0
 * @date 2024-04-10
 */
@Data
@ApiModel("枚举项")
public class BaseEnumItem {
    public BaseEnumItem() {
    }

    public BaseEnumItem(ObjectEnum objectEnum) {
        Objects.requireNonNull(objectEnum, "枚举不能为空");
        this.value = objectEnum.getValue();
        this.desc = objectEnum.getDesc();
    }

    @ApiModelProperty("枚举值")
    private Object value;

    @ApiModelProperty("枚举描述")
    private String desc;

    public static BaseEnumItem of(ObjectEnum objectEnum) {
        return new BaseEnumItem(objectEnum);
    }

}
